
<template>
<view class="user-order" style="margin-top: -0rpx;">
    <tabs :current="active" @change="changeShow" bar-width="60" :is-scroll="false">
        <tab v-for="(item, index) in order" :key="index" :name="item.name">
            <order-Track  :order-type="item.type" :i="index" :index="active"></order-Track>
        </tab>
    </tabs>
	<float-tab></float-tab>
</view>
</template>

<script>

import { orderTrack } from '@/utils/type';

export default {
  data() {
    return {
      active: -1,
      order: [{
        name: '全部',
        type: orderTrack.ALL
      },{
        name: '客户指派',
        type: orderTrack.SERVE
      }, {
        name: '确认尾款',
        type: orderTrack.PAY
      }, {
        name: '确认发货',
        type: orderTrack.DELIVERY
      },
	  // {
   //      name: '确认收货',
   //      type: orderTrack.FINISH
   //    },
	  // {
   //      name: '确认安装',
   //      type: orderTrack.FINISH
   //    },
	  ]
    };
  },
  onLoad (options) {
    const{order} = this
    let type = this.$Route.query.type || orderTrack.ALL;
	let index = order.findIndex(item => item.type == type)
    this.changeShow(index);
  },
  onShow(){
	uni.$on('payment', params => {
		setTimeout(() => {
			if (params.result) {
				this.$Router.replace({
					path: '/bundle/pages/pay_result/pay_result',
					query: {
						id: params.order_id,
						from: params.from,
						type: params.finaltype,
					}
				})
			} else {
				this.$Router.replace({
					path: '/bundle/pages/user_order/user_order'
				})
			}
		}, 1 * 1000)
	})
  },
  methods: {
    changeShow(index) {
		if(index != -1) {
			this.$nextTick(() => {
				this.active = index
				 // console.log(777)
			})
		}
    // console.log(888)
    },
  }
};
</script>
<style>

</style>